@echo off
rem indexOf
set str=liuyalong
set indexChar=p
set /a indexValue=-1

call :indexOf indexValue %str% %indexChar%
echo %indexValue%
pause

exit

rem indexOf
rem param1 indexValue
rem param2 string
rem param3 searchChar
:indexOf
rem set default value

set /a %1=-1
set strTmp=%2%
set /a idx=0
:loop
	set tc=%strTmp:~0,1%
	if "%tc%" equ "%3" (
		set /a %1=%idx%
		goto methEnd
	) else (
		set /a idx+=1	
		set strTmp=%strTmp:~1%
	)
if "" equ "%strTmp%" (
	goto methEnd 
) else (
	goto loop
) 
:methEnd

goto :eof
